package com.league.blog.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author admin
 * Time:2019-05-16 10:51
 * Description:日期、时间工具
 */
public class DataUtils {

    private final static String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

    private final static String NO_FORMAT = "yyyyMMddHHmmss";

    public final static String SHORT_FORMAT = "";

    /**
     * 获取系统当前时间，默认格式为yyyy-MM-dd HH:mm:ss
     * @return
     */
    public static String getCurrentDate(){
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        return sdf.format(new Date());
    }

    /**
     * 获取系统当前时间，格式为传入的参数，所以不要瞎鸡儿传
     * @return
     */
    public static String getCurrentDate(String data_format){
        SimpleDateFormat sdf = new SimpleDateFormat(data_format);
        return sdf.format(new Date());
    }

    /**
     * 获取没有格式的日期字符串，例如：20190531144722
     * @return
     */
    public static String getNoFormatDate(){
        SimpleDateFormat sdf = new SimpleDateFormat(NO_FORMAT);
        return sdf.format(new Date());
    }
}
